package com.gang.mars.basic.annotation;

import java.lang.annotation.Annotation;

/**
 * @author gang.chen
 * @description
 * @Date 2021/7/12 13:58
 */

public class AnnotationTest {
    public static void main(String[] args) {
        Annotation[] annotations = new AnnotationTest().readAnnotation(MyAnnotation.class);
        System.out.println(annotations);

        String annotationValue = new AnnotationTest().getAnnotationValue(MyConfiguration.class);
        System.out.println(annotationValue);
    }

    public Annotation[] readAnnotation(Class aClass){
        Annotation[] declaredAnnotations = aClass.getDeclaredAnnotations();
        return declaredAnnotations;
    }

    public String getAnnotationValue(Class<?> clazz){
        MyAnnotation annotation = clazz.getAnnotation(MyAnnotation.class);
        String value = annotation.value();
        return value;
    }
}
